package com.ss.ttvideoengine.b;

import android.text.TextUtils;

import org.json.JSONArray;

import java.util.ArrayList;
import java.util.List;

public final class VideoAdInfo {
    public String logExtra;
    public int skipTime;
    public int patchPosition;
    public int duration;
    public long id;
    public String externalUrl;
    public List playTrackUrlList;
    public VideoItem mVideoItem1;
    public VideoItem mVideoItem2;
    public VideoItem mVideoItem3;


    public static List<String> extractList(Object obj, String[] array) {
        array[0] = null;
        if (obj != null) {
            try {
                if ((obj instanceof String)) {
                    ArrayList<String> result = new ArrayList();
                    result.add((String) obj);
                    array[0] = (String) obj;
                    return result;
                }

                if (obj instanceof JSONArray) {
                    JSONArray ja = (JSONArray) obj;
                    int length = ja.length();
                    if (length == 0) {
                        return null;
                    }

                    ArrayList<String> result = new ArrayList();
                    for (int i = 0; i < length; i++) {
                        String str = ja.getString(i);
                        if (!TextUtils.isEmpty(str)) {
                            result.add(str);
                        }
                    }
                    if (result.isEmpty()) {
                        return null;
                    }
                    array[0] = ja.toString();
                    return result;
                } else {
                    return null;
                }

            } catch (Exception exception) {
            }
        }
        return null;
    }
}

